package chaowan.Service.impl;

import chaowan.Mapper.GoodsCategoryMapper;
import chaowan.Service.GoodsCategoryService;
import chaowan.pojo.GoodsCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsCategoryServiceImpl implements GoodsCategoryService {

    @Autowired
    private GoodsCategoryMapper goodsCategoryMapper;

    @Override
    public List<GoodsCategory> findAll() {
        return goodsCategoryMapper.selectAll();
    }

    @Override
    public GoodsCategory findById(Long cid) {
        return goodsCategoryMapper.selectById(cid);
    }

    @Override
    public GoodsCategory save(GoodsCategory category) {
        goodsCategoryMapper.insert(category);
        return category;
    }

    @Override
    public GoodsCategory update(GoodsCategory category) {
        goodsCategoryMapper.update(category);
        return category;
    }

    @Override
    public void deleteById(Long cid) {
        goodsCategoryMapper.deleteById(cid);
    }

    @Override
    public List<GoodsCategory> list() {
        return goodsCategoryMapper.findAllActive();
    }
}